<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.daogou.model.TBItems"%>
<%@ page import="com.inter.Taobao"%>
<%@ page import="com.inter.Taobao"%>
<%@ page import="com.taobao.api.ApiException"%>
<%@ page import="com.taobao.api.domain.TaobaokeItem"%>
<%@ page import="java.util.List"%><%@page import="java.net.URLEncoder"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>List Goods</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<style type="text/css">
		*{
			color:#48A0C6;
			font-family:sans-serif;
		}
		a{
			text-decoration: none;
		}
		a.a_visit{
			color:#555555;
		}
		a:hover{
			text-decoration: underline;
			color:#FF801F;
		}
		#main{
		/*	border:1px solid red;
		*/	width:600px;
			height:1000px;
			margin:auto;
		}
		#main .goods{
			width:100%;
			height:120px;
		/*	border:1px solid blue;
		*/
		}
		.left{	
			float:left;
			width:120px;
			height:120px;
		}
		.middle{
		/*	border:1px solid black;
		*/	padding:5px;
			font-size:12px;
			float:left;
			width:200px;
			height:100px;
		}
		.right{
			float:left;
			width:200px;
		}
		font{
			font-weight:900;
			color:#FF2900;
		}
		e{
			color:#838383;
		}
		hr{
			width:100%;
		}
	</style>

  </head>
  
  <body>
    <div id="main">
    	<%
    		request.setCharacterEncoding("utf-8");
		    response.setCharacterEncoding("utf-8");
    		List<TaobaokeItem> list = (List<TaobaokeItem>)request.getAttribute("list");
    		long cpage = Long.parseLong(request.getAttribute("cpage").toString());
    		long pages = Long.parseLong(request.getAttribute("pages").toString());
    		String key = request.getAttribute("key").toString();
    		key = URLEncoder.encode(key);
    		for(TaobaokeItem item:list){
    			out.print("<div class='goods'>");
    			
    			out.print("<div class='left'>");
    			out.print("<img src='"+item.getPicUrl()+"_120x120.jpg'/>");
    			out.print("</div>");
    			
    			out.print("<div class='middle'>");
    			out.print("<a href='"+item.getClickUrl()+"'>"+item.getTitle()+"</a><br><br><br>");
    			out.print("&nbsp&nbsp&nbsp&nbsp<a class='a_visit' href='"+item.getClickUrl()+"'>访问店铺</a>&nbsp&nbsp&nbsp");
    			out.print("<a class='a_visit' href='../servlet/CollectGoods?gid="+item.getNumIid()+
    							"&picurl="+item.getPicUrl()+
    							"&price="+item.getPrice()+
    							"&commission="+item.getCommission()+
    							"&title="+item.getTitle()+
    							"&clickurl="+item.getClickUrl()+"'>加入收藏</a>");
    			out.print("</div>");
    			
    			out.print("<div class='right'>");
    			out.print("<e>价格:￥</e><font>"+item.getPrice()+"</font><br>");
    			out.print("<e>返利:￥</e><font>"+item.getCommission()+"</font>");
    			out.print("</div>");
    			
    			out.print("</div><hr style=\"margin-top:30px;\"><br>");
    		}
    		out.print("<a href=\"../servlet/SearchGoods?cpage=1&key="+key+"\">首页</a>");
    		long spage, epage;
    		spage = cpage - 5;
    		epage = cpage + 5;
    		spage = (spage < 1)? 1:spage;
    		epage = (epage > pages)? pages:epage;
    		for(long i = spage; i < epage; i++){
    			out.print(" <a ");
    			if(i != cpage)
    				out.print("href=\"../servlet/SearchGoods?cpage=" +(i)+ "&key="+key+"\"");
    			out.print(">"+(i)+"</a> ");
    		}
    		out.print("<a href=\"../servlet/SearchGoods?cpage="+pages+"&key="+key+"\">末页</a>");
    	 %>
    </div>
  </body>
</html>
